package com.monitor.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.monitor.common.annotation.Log;
import com.monitor.common.core.controller.BaseController;
import com.monitor.common.core.domain.AjaxResult;
import com.monitor.common.enums.BusinessType;
import com.monitor.system.domain.ThresholdManagement;
import com.monitor.system.service.IThresholdManagementService;
import com.monitor.common.utils.poi.ExcelUtil;
import com.monitor.common.core.page.TableDataInfo;

/**
 * 阈值管理Controller
 * 
 * @author monitor
 * @date 2024-06-21
 */
@RestController
@RequestMapping("/system/thresholdManagement")
public class ThresholdManagementController extends BaseController
{
    @Autowired
    private IThresholdManagementService thresholdManagementService;

    /**
     * 查询阈值管理列表
     */
//    @PreAuthorize("@ss.hasPermi('system:thresholdManagement:list')")
    @GetMapping("/list")
    public TableDataInfo list(ThresholdManagement thresholdManagement)
    {
        startPage();
        List<ThresholdManagement> list = thresholdManagementService.selectThresholdManagementList(thresholdManagement);
        return getDataTable(list);
    }

    /**
     * 导出阈值管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:thresholdManagement:export')")
    @Log(title = "阈值管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ThresholdManagement thresholdManagement)
    {
        List<ThresholdManagement> list = thresholdManagementService.selectThresholdManagementList(thresholdManagement);
        ExcelUtil<ThresholdManagement> util = new ExcelUtil<ThresholdManagement>(ThresholdManagement.class);
        util.exportExcel(response, list, "阈值管理数据");
    }

    /**
     * 获取阈值管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:thresholdManagement:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(thresholdManagementService.selectThresholdManagementById(id));
    }

    /**
     * 新增阈值管理
     */
    @PreAuthorize("@ss.hasPermi('system:thresholdManagement:add')")
    @Log(title = "阈值管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ThresholdManagement thresholdManagement)
    {
        return toAjax(thresholdManagementService.insertThresholdManagement(thresholdManagement));
    }

    /**
     * 修改阈值管理
     */
//    @PreAuthorize("@ss.hasPermi('system:thresholdManagement:edit')")
    @Log(title = "阈值管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ThresholdManagement thresholdManagement)
    {
        return toAjax(thresholdManagementService.updateThresholdManagement(thresholdManagement));
    }

    /**
     * 删除阈值管理
     */
    @PreAuthorize("@ss.hasPermi('system:thresholdManagement:remove')")
    @Log(title = "阈值管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(thresholdManagementService.deleteThresholdManagementByIds(ids));
    }
}
